#!/bin/sh
set -e
BUILD="$(pwd)"
newline="
"

if test -f "$BUILD"/x265_options ; then
    IFS=$newline
    set -- $(cat "$BUILD"/x265_options) "$@"
    unset -v IFS
fi

OPTIONS="-DENABLE_SHARED=ON -DENABLE_PIC=ON"

case "$PKG_CONFIG_PATH" in
  '')
    export PKG_CONFIG_PATH="$BUILD/build_libs/lib/pkgconfig"
    ;;
  *)
    export PKG_CONFIG_PATH="$BUILD/build_libs/lib/pkgconfig:$PKG_CONFIG_PATH"
    ;;
esac

cd "$BUILD"/x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$BUILD/build_libs" $OPTIONS "$@" ../../source

